<template>
    <div class="progress-container">
      <div 
        v-for="(step, index) in steps" 
        :key="index"
        class="step-item"
        :class="{
          'active': index <= currentStep,
          'first': index === 0,
          'last': index === steps.length - 1
        }"
      >
        {{ step.name }}（{{ step.progressCoefficient }}）
        <div v-if="!isLast(index)" class="arrow"></div>
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref } from 'vue'
  
// 定义 props
const props = defineProps({
  steps: {
    type: Array,
    required: true
  },
  initialStep: {
    type: Number,
    default: 0
  }
})

const currentStep = ref(props.initialStep)

const isLast = (index) => {
  console.log('666 :>> ', 666);
  return index === props.steps.length - 1
}
  </script>
  
  <style scoped>
  .progress-container {
    /* display: flex; */
    width: 100%;
    margin: 10px 0;
    position: relative;
    overflow-x: hidden;
    border-radius: 14px;
    white-space: nowrap;

  }
  
  .step-item {
    flex: 1;
    padding: 6px 20px;
    background-color: #F08080;
    color: white;
    text-align: center;
    position: relative;
    font-size: 12px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 24px;
    min-width: 90px;
    display: inline-block;
  }
  
  .arrow {
    width: 0;
    height: 0;
    border-top: 18px solid transparent;
    border-bottom: 18px solid transparent;
    border-left: 10px solid #F08080;
    position: absolute;
    right: -10px;
    top: 0;
    z-index: 2;
  }
  
  .step-item::before {
    content: '';
    position: absolute;
    right: -11px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 18px solid transparent;
    border-bottom: 18px solid transparent;
    border-left: 10px solid white;
    z-index: 1;
  }
  .first{
    
    border-top-left-radius: 14px;
    border-bottom-left-radius: 14px;
  }
  .step-item.active {
    background-color: #529B2E;
  }
  
  .step-item.active .arrow {
    border-left-color: #529B2E;
  }
  
  .step-item.last {
    border-top-right-radius: 14px;
    border-bottom-right-radius: 14px;
  }
  
  .step-item.last::before {
    display: none;
  }
  
  .step-item {
    padding-right: 15px;
  }
  
  .step-item.last {
    padding-right: 10px;
  }
  </style>
  
  